<template>
    <div class="hospital-item">
        <div class="hospital-image">
            <img :src="hospital.image || '/images/hospital-default.jpg'" alt="医院图片" />
        </div>
        <div class="hospital-info">
            <div class="hospital-name">{{ hospital.name }}</div>
            <div class="hospital-tags">
                <span class="tag">{{ hospital.level }}</span>
                <span class="tag">{{ hospital.type }}</span>
            </div>
            <div class="hospital-address">
                <van-icon name="location-o" />
                <span>地址: {{ hospital.address }}</span>
            </div>
            <div class="hospital-actions">
                <van-button size="small" type="primary" plain @click="onViewHospital">查看医院</van-button>
                <van-button size="small" type="primary" @click="onBookAppointment">可挂号</van-button>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'

interface HospitalProps {
    hospital: {
        id: number
        name: string
        image?: string
        level: string
        type: string
        address: string
    }
}

const props = defineProps<HospitalProps>()
const router = useRouter()

const onViewHospital = () => {
    router.push(`/hospital/${props.hospital.id}`)
}

const onBookAppointment = () => {
    router.push(`/hospital/${props.hospital.id}/booking`)
}
</script>

<style scoped lang="scss">
.hospital-item {
    margin: 5px;
    padding: 16px;
    background: #fff;
    display: flex;
    border-bottom: 1px solid #f5f5f5;

    .hospital-image {
        width: 80px;
        height: 80px;
        margin-right: 12px;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 4px;
        }
    }

    .hospital-info {
        flex: 1;

        .hospital-name {
            font-size: 16px;
            font-weight: 500;
            color: #333;
            margin-bottom: 8px;
        }

        .hospital-tags {
            margin-bottom: 8px;

            .tag {
                display: inline-block;
                background: #f5f5f5;
                padding: 2px 6px;
                border-radius: 4px;
                font-size: 12px;
                color: #666;
                margin-right: 8px;
            }
        }

        .hospital-address {
            display: flex;
            align-items: center;
            font-size: 12px;
            color: #999;
            margin-bottom: 8px;

            .van-icon {
                margin-right: 4px;
            }
        }

        .hospital-actions {
            display: flex;
            gap: 8px;
        }
    }
}
</style>